package com.fs.uc.base.exception;

import io.quarkus.runtime.annotations.RegisterForReflection;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 崔超
 * 2021/12/17
 */
@Provider
@RegisterForReflection
public class ExceptionMapper implements javax.ws.rs.ext.ExceptionMapper<Exception> {
    @Override
    public Response toResponse(Exception throwable) {
        Map<String, Object> map = new HashMap<>();
        map.put("success", false);
        map.put("msg", throwable.getMessage());
        return Response.serverError().entity(map).build();
    }
}
